#include "threadPool.h"

int recvn(int netfd, void *buf, int length)
{
    int total = 0;//已经recv的总字节数
    char *p = (char *)buf;//void * --> char *
    while(total < length)
    {
        int ret = recv(netfd,p+total,length-total,0);
        if(ret == 0)
        {
            return -1;
        }
        total += ret;
    }
    return 0;
}

int initThreadPool(threadPool_t *thread_pool, int worker_num)
{
    thread_pool->tid_arr = (pthread_t *)calloc(worker_num,sizeof(pthread_t));
    thread_pool->worker_num = worker_num;
    queueInit(&thread_pool->task_queue);
    thread_pool->exit_flag = 0;
    thread_pool->password = 0;

    return 0;
}

int orderValue(order_t *order,int netfd)
{
    recvn(netfd,order,sizeof(order_t));
    return 0;
}
